import { PageModel } from '@/types/model'

/**
 * 分页后数据
 */
export function pageModel<T>(data: T[], args: Record<string, any>): PageModel<T> {
  const { page } = args
  const row = 10
  const total = data.length

  if (page) {
    const start = (page - 1) * row
    const end = start + row
    data = data.slice(start, end)
  }

  return {
    data,
    meta: {
      row,
      total,
    },
  }
}
